$(function() {

})


function search() {
	$("input[name='pageNum']").val(1);
	$("#searchForm").submit();
}

function add() {
	$("#id").val("");
	$("#name").val("");

	form.render();
	showWindow("添加仓库");
}


function showWindow(title) {
	layer.open({
		type: 1,
		title: title,
		area: ['400px', '200px'], // 宽高
		content: $('#windowDiv')
	});
}

function addOver() {
	if ($("#name").val() == "") {
		layer.msg("仓库名为空");
		return;
	}

	showLoad();
	$.ajax({
		type: 'POST',
		url: ctx + '/adminPage/repository/addOver',
		data: {
			id: $("#id").val(),
			name: $("#name").val()
		},
		dataType: 'json',
		success: function(data) {
			closeLoad();
			if (data.success) {
				location.reload();
			} else {
				layer.msg(data.msg);
			}
		},
		error: function() {
			closeLoad();
			alert("出错了,请联系技术人员!");
		}
	});
}


function del(id) {
	if (confirm("确认删除?")) {
		showLoad();
		$.ajax({
			type: 'POST',
			url: ctx + '/adminPage/repository/del',
			data: {
				id: id
			},
			dataType: 'json',
			success: function(data) {
				closeLoad();
				if (data.success) {
					location.reload();
				} else {
					layer.msg(data.msg)
				}
			},
			error: function() {
				closeLoad();
				alert("出错了,请联系技术人员!");
			}
		});
	}
}


function copy(str){
    copyToClipboard(str);
}


function groupPermission(id){
	layer.open({
		  type: 2, 
		  title: '小组授权',
		  area : [  '1000px', '720px;'  ],
		  content: ctx + "/adminPage/repository/groupPermission?repositoryId=" + id
	});
}

function userPermission(id){
	layer.open({
		  type: 2, 
		  title: '用户授权',
		  area : [ '1000px', '720px;' ],
		  content: ctx + "/adminPage/repository/userPermission?repositoryId=" + id
	});
}
